<DOCTYPE html>
  <html lang="en">

  <head charset="utf-8">
    <title></title>
  </head>

  <body>
    <script>
      function Set() {
        this.items = {};

        Set.prototype.has = key => {
          for (let i = 0; i < this.size(); i++) {
            if (key == this.size()[i]) {
              return true
            }
          }
          return false
        }

        Set.prototype.add = key => {
          if (!this.has(key)) {
            this.items[key] = key
          }
        }

        Set.prototype.remove = key => {
          if (this.has(key)) {
            delete this.items[key]
            return true
          }
          return false
        }

        Set.prototype.clear = () => {
          this.items = {}
        }

        Set.prototype.size = () => {
          return Object.keys(this.items).length
        }

        Set.prototype.value = () => {
          return Object.keys(this.items)
        }

        Set.prototype.union = otherItems => {
          let unionItems = this.items;
          for (let i = 0; i < otherItems.size(); i++) {
            unionItems.add(otherItems.value()[i]);
          }
          return unionItems.value()
        }

        Set.prototype.intersection = otherItems => {
          let intersectionItems = new Set();
          for (let i = 0; i < this.size(); i++) {
            for (let j = 0; j < otherItems.size(); j++) {
              if (this.value()[i] == otherItems.value()[j]) {
                intersectionItems.add(this.value()[i]);
              }
            }
          }
          return inertsectionItems.value()
        }

        Set.prototype.diffrence = otherItems => {
          let diffrenceItems = new Set();
          for (let i = 0; i < this.size(); i++) {
            for (let j = 0; j < otherItems.size(); j++) {
              if (this.value()[i] == otherItems.value()[j]) {
                break;
              }
              diffrenceItems.add(this.value()[i]);
            }
          }
          return diffrenceItems.value()
        }

        Set.prototype.subset = otherItems => {
          for (let i = 0; i < this.size(); i++) {
            if (!otherItems.has(this.value()[i])) {
              return false
            }
          }
          return true
        }
      }
    </script>
  </body>

  </html>